﻿// <copyright file="Enum.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-03-25</date>
// <summary>opensocial.Enum wrapper class</summary>

namespace opensocial
{
    using System.Diagnostics.CodeAnalysis;
    using System.Windows.Browser;

    /// <summary>
    /// Wrapper around opensocial.Enum class
    /// </summary>
    [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Enum", Justification = "This is the opensocial.Enum class."),
     SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "This is the opensocial.Enum class.")]
    public class Enum
    {
        /// <summary>
        /// Initializes a new instance of the Enum class.
        /// </summary>
        /// <param name="scriptObject">the JavaScript opensocial.Enum class</param>
        public Enum(ScriptObject scriptObject)
        {
            if (scriptObject == null)
            {
                return;
            }

            this.Key = scriptObject.Invoke("getKey", null) as string;

            this.DisplayValue = scriptObject.Invoke("getDisplayValue", null) as string;
        }

        /// <summary>
        /// Gets or sets the key
        /// </summary>
        public string Key { get; set; }

        /// <summary>
        /// Gets or sets the display name
        /// </summary>
        public string DisplayValue { get; set; }

        /// <summary>
        /// Gets the properties for the object
        /// </summary>
        /// <returns>a string listing the non-null properties and their values.</returns>
        public override string ToString()
        {
            return Synergist.Utility.GetProperties(this);
        }
    }
}
